﻿using System.Diagnostics.Contracts;
using System.IO;

namespace OpenLS.Spreadsheet.Formats.Biff.Records
{
    class ExternDocName: ExternNameStructure
    {
        private ShortXLUnicodeString extName;
        public override string Name { get { return (string) extName; } }
        private ushort ixals;
        private ExtNameParsedFormula nameDefinition;

        public override void Read(BinaryReader reader)
        {
            this.ixals = reader.ReadUInt16();
            var reserved = reader.ReadUInt16();
            Contract.Assert(reserved == 0);
            extName.Read(reader);
            nameDefinition = new ExtNameParsedFormula();
            this.nameDefinition.Read(reader);
        }
        public override void Write(BinaryWriter writer)
        {
            writer.Write(ixals);
            writer.Write((ushort)0);
            extName.Write(writer);
            this.nameDefinition.Write(writer);
        }
    }
}